﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;

public partial class WebPages_Barber_BarberTypeAdd : BasePage
{
    public int Id
    {
        get
        {
            return string.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : Convert.ToInt32(Request.QueryString["id"]);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BandBarberTypeInfo();
        }
    }
    //添加
    protected void btn_add_Click(object sender, EventArgs e)
    {
        string name = txt_name.Text.Trim();
        BarberShop.Data.BarberType info=new BarberShop.Data.BarberType();
        if (Id != 0)
        {
            info = BarberShop.BLL.BarberTypeBLL.GetBarberType(Id);
            info.Name = name;
            BarberShop.BLL.BarberTypeBLL.UpdateBarberType(info);
            MessageBox.Show(this.Page, "修改类别成功！");
            return;
        }
        info.Name=name ;
        info.CreateDate = DateTime.Now;
        bool r=BarberShop.BLL.BarberTypeBLL.AddBarberType(info);
        if(r)
            MessageBox.Show(this.Page, "添加类别成功！");
    }
    //load
    public void BandBarberTypeInfo()
    {
        if (Id != 0)
        {
            var info = BarberShop.BLL.BarberTypeBLL.GetBarberType(Id);
            txt_name.Text = info.Name;
        }
    }
}